package com.lianjinsu.shop.repository.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.lianjinsu.shop.core.mybatis.AdvancedDaoImpl;
import com.lianjinsu.shop.entity.OrdersRef;
import com.lianjinsu.shop.repository.dao.OrdersRefDao;
import com.lianjinsu.shop.repository.mapper.OrdersRefMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrdersRefDaoImpl extends AdvancedDaoImpl<OrdersRefMapper, OrdersRef> implements OrdersRefDao {

    @Override
    public List<OrdersRef> ordersRefList(String tradeSn) {
        LambdaQueryWrapper<OrdersRef> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(OrdersRef::getTradeSn, tradeSn);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<OrdersRef> ordersRefList(List<String> tradeSnList) {
        LambdaQueryWrapper<OrdersRef> wrapper = Wrappers.lambdaQuery();
        wrapper.in(OrdersRef::getTradeSn, tradeSnList);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public boolean removeByTradeSn(String tradeSn) {
        LambdaUpdateWrapper<OrdersRef> wrapper = Wrappers.lambdaUpdate();
        wrapper.eq(OrdersRef::getTradeSn, tradeSn);
        return remove(wrapper);
    }
}
